package com.horay.springclouddemo.stream.multiple.provider.service.impl;

import com.horay.springclouddemo.stream.multiple.provider.message.MessageSource;
import com.horay.springclouddemo.stream.multiple.provider.service.MessageChannelService;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * 消息通道业务实现类
 *
 * @author heyingcheng
 * @date 2020/3/29 17:00
 */
@Service
public class MessageChannelServiceImpl implements MessageChannelService {

    private MessageSource messageSource;

    public MessageChannelServiceImpl(MessageSource messageSource) {
        this.messageSource = messageSource;
    }

    @Override
    public String send() {
        String serial = UUID.randomUUID().toString();
        messageSource.logOutput().send(MessageBuilder.withPayload(serial).build());
        return serial;
    }

}
